<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang='en'>
<head>
	<meta charset='utf-8' />
	<title>广溢信息技术有限公司</title>
	<meta content='' name='description' />
	<meta content='' name='author' />
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<!-- Bootstrap -->
	<link href="__PUBLIC__/css/bootstrap.min.css" rel="stylesheet" >
    <link href="__PUBLIC__/css/jquery-ui-1.9.2.custom.css" rel="stylesheet" />
	<link href="__PUBLIC__/css/font-awesome.min.css" rel="stylesheet" >

	<!--[if IE 7]>
		<link  href="__PUBLIC__/css/font-awesome-ie7.min.css" rel="stylesheet">
	<![endif]-->

	<!--[if lt IE 9]>
		<link type="text/css" href="__PUBLIC__/css/custom-theme/jquery.ui.1.9.2.ie.css"  rel="stylesheet" />
	<![endif]-->

	<link href="__PUBLIC__/css/bootstrap-responsive.css" rel="stylesheet">
	<link href="__PUBLIC__/css/test.css" rel="stylesheet">
	<script src="__PUBLIC__/js/jquery.js"></script>

	<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
	<!--[if lt IE 9]>
	<script src="__PUBLIC__/js/html5shiv.js"></script>
	<script src="__PUBLIC__/js/respond.min.js"></script>
	<![endif]-->
	<script type="text/javascript">
	var upload_url="<?php echo U('file/upload?module='.MODULE_NAME);?>";
	var del_url="<?php echo U('File/del');?>";
	var session_id="<?php echo session_id();?>";	
	var _hmt = _hmt || [];
	(function() {
	  var hm = document.createElement("script");
	  hm.src = "//hm.baidu.com/hm.js?2a935166b0c9b73fef3c8bae58b95fe4";
	  var s = document.getElementsByTagName("script")[0]; 
	  s.parentNode.insertBefore(hm, s);
	})();
</script>
</head>
<body>
	<div class="shade"></div>
	<div class="row-fluid navbar visible-phone">
	<div class="row-fluid">
		<a class="brand" href="<?php echo U('home/index');?>">广溢网络</a>
		<a data-toggle="collapse" data-target="#top_menu" class="right">
		<i class="brand icon-th-list"></i>
		</a>
	</div>
	<div class="col-lapse" id="top_menu">
		<ul class="nav nav-pills">
			<?php if(is_array($list_top_menu)): $i = 0; $__LIST__ = $list_top_menu;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$tag): $mod = ($i % 6 );++$i;?><li>
					<a  href="#" url="<?php echo U($tag['url']);?>" node="<?php echo ($tag["id"]); ?>" onclick="click_top_menu(this)"><?php echo ($tag["name"]); ?></a>
				</li><?php endforeach; endif; else: echo "" ;endif; ?>
		</ul>
	</div>
</div>
<div class="row-fluid navbar hidden-phone">
	<a class="brand" href="<?php echo U('home/index');?>">广溢网络</a>
	<ul class="nav nav-pills">
		<?php if(is_array($list_top_menu)): $i = 0; $__LIST__ = $list_top_menu;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$tag): $mod = ($i % 6 );++$i;?><li>
				<a  href="#" url="<?php echo U($tag['url']);?>" node="<?php echo ($tag["id"]); ?>" onclick="click_top_menu(this)"><?php echo ($tag["name"]); ?></a>
			</li><?php endforeach; endif; else: echo "" ;endif; ?>
	</ul>
	<aside>
		<span>
			<a href="<?php echo U('UserConfig/index');?>">设置</a>
		</span>
		<span>
			<a href="<?php echo U('profile/index');?>"><?php echo (session('user_name')); ?></a>
		</span>
		<span>
			<a href="<?php echo U('login/logout');?>">退出</a>
		</span>
		&nbsp;&nbsp;
	</aside>
</div>

	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span3 left_menu">
				<div class="visible-phone">
	<h4 class="btn no-border" data-toggle="collapse" data-target="#left_menu">		
			<?php echo ($top_menu_name); ?><i class="icon-angle-down"></i>
		</h4>
	<div class="col-lapse" id="left_menu"><?php echo ($html_left_menu); ?></div>
</div>
<div class="hidden-phone">
	<h4><?php echo ($top_menu_name); ?></h4>
	<div><?php echo ($html_left_menu); ?></div>
</div>
			</div>
			<div class="span9 content">
<script type="text/javascript">
  /*
	function edit() {
		window.location = "<?php echo U('read?id='.$vo['id']);?>";
	}
  */
</script>

<div class="customer">
  <?php $kehu = $vo['kehu'] ; ?>
  <div class="row-fluid title">
    <a href="javascript:void($('#jiben_xinxi').toggle());"><span>客户信息：<?php echo ($kehu["name"]); ?></span></a>
  </div>
  <div id="jiben_xinxi" style="display:none;">
    <form method='post' id="form_data" class="row-fluid">
      <input type="hidden" name="id" value="<?php echo ($vo["id"]); ?>">
      <input type="hidden" name="ajax" id="ajax" value="1">
      <div class="row-fluid form_box">
        <div class="row-fluid form-horizontal">
          <div class="control-group span6">
            <label class="control-label" for="name">客户名称：</label>
            <div class="controls">
              <?php echo ($kehu["name"]); ?>
            </div>
          </div>
          <div class="control-group span6">
            <label class="control-label" for="company">客户网站：</label>
            <div class="controls">
              <a href='http://<?php echo ($kehu["web_url"]); ?>' target="_blank"><?php echo ($kehu["web_url"]); ?></a>
            </div>
          </div>
        </div>
        <div class="row-fluid form-horizontal">
          <div class="control-group span6">
            <label class="control-label" for="dept">客户地址：</label>
            <div class="controls">
              <?php echo ($kehu["sel0"]); echo ($kehu["sel1"]); echo ($kehu["sel2"]); echo ($kehu["address"]); ?></div>
          </div>
          <div class="control-group span6">
            <label class="control-label" for="position">行业：</label>
            <div class="controls">
              <?php echo ($kehu["trade"]); ?></div>
          </div>
        </div>
        <div class="row-fluid form-horizontal">
          <div class="control-group span6">
            <label class="control-label" for="office_tel">企业法人：</label>
            <div class="controls">
              <?php echo ($kehu["legal_person"]); ?></div>
          </div>
          <div class="control-group span6">
            <label class="control-label" for="mobile_tel">注册资金：</label>
            <div class="controls">
              <?php echo ($kehu["fund"]); ?></div>
          </div>
        </div>
        <div class="row-fluid form-horizontal">
          <div class="control-group span6">
            <label class="control-label" for="email">注册日期：</label>
            <div class="controls">
              <?php echo ($kehu["fund_date"]); ?></div>
          </div>
          <div class="control-group span6">
            <label class="control-label" for="im">主要业务范围：</label>
            <div class="controls">
              <?php echo ($kehu["main_business"]); ?></div>
          </div>
        </div>
        <div class="row-fluid form-horizontal">
          <div class="control-group span6">
            <label class="control-label" for="website">主要客户群：</label>
            <div class="controls">
              <?php echo ($kehu["main_client_base"]); ?></div>
          </div>
          <div class="control-group span6">
            <label class="control-label" for="address">营业范围：</label>
            <div class="controls">
              <?php echo ($kehu["business_rang"]); ?></div>
          </div>
        </div>
        <div class="row-fluid form-horizontal">
          <div class="control-group span6">
            <label class="control-label" for="website">营业区域：</label>
            <div class="controls">
              <?php echo ($kehu["business_area"]); ?></div>
          </div>
          <div class="control-group span6">
            <label class="control-label" for="address">其他：</label>
            <div class="controls">
              <?php echo ($kehu["description"]); ?></div>
          </div>
        </div>
      </div>
      <div class="action">
        <input  class="btn" type="button" value="返回" onclick="go_return_url();">
      </div>
    </form>
  </div>
</div>

<script type="text/javascript">
	function add() {
   // alert(3333);
		$("#form_lianxiren :input :not(:button)").each(function() {
    //  alert($(this).val());
			$(this).val("");
		});
		$("#form_lianxiren :text").each(function() {
			$(this).val("");
		});
		$("#form_lianxiren select").each(function() {
			$(this).find('option:first').attr('selected', 'selected');
		});
		$(".sub_left_menu tr.active").removeClass("active");
		$("#opmode").val("add");
	}

	function save() {
		//$("#pic").val($("#save_name").val().split(";")[0]);
		if(check_form("form_lianxiren")){
      sendForm("form_lianxiren", "<?php echo U('contact_person/save');?>",window.location.href);
			//sendForm("form_lianxiren", "<?php echo U('contact_person/save');?>","__URL__");
		}		
	}

  function destroy() {
    var id = $(".sub_left_menu  tr.active").attr('id');
    if(id==undefined){
      alert('请先选择联系人');
      return false;
    }
    sendAjax("<?php echo U('contact_person/del');?>", "id=" + id, function(data) {
        if(data['status']=='1'){
          alert(data['info']);
        }else{
          alert('未成功！'); 
        };
       location.reload();
    });
  }

	function showdata(result) {
		for (var s in result.data) {
			set_val(s,result.data[s]);
		}
		$("#dept_name").val($("#dept_list option[value='" + $("#dept_id").val() + "']").text());
		img_url = "<?php echo C('SAVE_PATH');?>" + $("#pic").val();
		$("#emp_pic").attr("src", img_url.split(";")[0]);
		$("#save_name").val("");
		$("#opmode").val("edit");
	}

	$(document).ready(function(){		
		$(".input-date").datepicker();

		$(".sub_left_menu  tr").click(function() {
			$(".sub_left_menu  tr.active").removeClass("active");
			$(this).attr("class","active");
      //alert($(this).attr('id'));
			sendAjax("<?php echo U('contact_person/read');?>", "id=" + $(this).attr("id"), function(data) {
       // alert(data);
				showdata(data);
			});
			return false;
		})
	});

</script>
<div class="admin" >
	<form method="post" action="" id="form_search" name="form_search">
		<div class="row-fluid title">
      <a href="javascript:void($('#lianxiren').toggle())">
        <span>联系人管理</span>
      </a>
		</div>
	</form>
  <div id="lianxiren" style="display:none;">
	<div class="row-fluid operate" >
		<div class="right">
			<a onclick="add()"  class="btn">新增</a>
			<a onclick="save()"  class="btn">保存</a>
			<a onclick="destroy()"  class="btn">删除</a>
		</div>
	</div>
	<div class="row-fluid">
		<div class="span4 sub_left_menu ">
			<table class="table table-bordered">
				<tr>
					<th>姓名</th>
					<th>手机</th>
					<th>电话</th>
				</tr>
        <?php $lianxiren_list = $vo['contact_people'] ?>
        <?php ?>
				<?php if(is_array($lianxiren_list)): $i = 0; $__LIST__ = $lianxiren_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$lianxiren): $mod = ($i % 2 );++$i;?><tr id="<?php echo ($lianxiren["id"]); ?>">
						<td><?php echo ($lianxiren["name"]); ?></td>
						<td><?php echo ($lianxiren["mobile"]); ?></td>
						<td><?php echo ($lianxiren["tel"]); ?></td>
					</tr><?php endforeach; endif; else: echo "" ;endif; ?>
			</table>
		</div>
		<div class="span8">
			<form id="form_lianxiren" name="form_lianxiren" method="post" action="">
				<input type="hidden" id="save_name" name="save_name">
				<input type="hidden" name="id" id="id">
				<input type="hidden" name="pid" id="pid" value="">
        <input type="hidden" name="mini_client_id" id="mini_client_id" value="<?php echo ($vo["id"]); ?>">
				<input type="hidden" name="pic" id="pic" >
				<input type="hidden" name="ajax" id="ajax" value="1">
				<input type="hidden" name="opmode" id="opmode" value="">
				<select type="select-one" id="dept_list" name="dept_list" onchange="" ondblclick="" class="dis" ><?php  foreach($dept_list as $key=>$val) { ?><option value="<?php echo $key ?>"><?php echo $val ?></option><?php } ?></select>
				<table class="table table-bordered" >
					<tr>
						<th>姓名*</th>
						<td>
              <input type="text" id="name" name="name" class="input-small" check="require" msg="请输入姓名">
            </td>
						<th>性别</th>
						<td>
							<select name="sex" id="sex" class="input-small">
								<option  value=1>男</option>
								<option value=2>女</option>
							</select>
						</td>
					</tr>
					<tr>
						<th>属性*</th>
						<td>
            <select type="select-one" id="contact_nature_id" name="contact_nature_id" onchange="" ondblclick="" class="input-small" ><option value="" >选择联系人性质</option><?php  foreach($contact_nature_list as $key=>$val) { ?><option value="<?php echo $key ?>"><?php echo $val ?></option><?php } ?></select>
						</td>
						<th>职务</th>
						<td>
              <input type="text" id="position" name="postion" class="input-small">
            </td>
					</tr>
					<tr>
						<th>手机</th>
						<td>
              <input type="text" id="mobile" name="mobile" class="input-small">
						</td>
						<th>电话</th>
						<td>
              <input type="text" id="tel" name="tel" class="input-small">
						</td>
					</tr>
					<tr>
						<th>电子邮箱</th>
						<td>
              <input type="text" id="email" name="email" class="input-small">
						</td>
						<th>QQ</th>
						<td>
              <input type="text" id="qq" name="qq" class="input-small">
						</td>
					</tr>
					<tr>
						<th>备注</th>
						<td colspan="3">
              <input type="text" id="description" name="description" class="span12">
						</td>
						</td>
					</tr>
				</table>
			</form>
		</div>
    <div id="contact_person_page">
    </div>
	</div>
</div>
</div>

<script type="text/javascript">
	function add_contact_record() {
		$("#form_lianxijilu :input :not(:button) :not('select')").each(function() {
			$(this).val("");
		});
		$("#form_lianxijilu :text").each(function() {
			$(this).val("");
		});
		$("#form_lianxijilu select").each(function() {
			$(this).find('option:first').attr('selected', 'selected');
		});
		$(".contact_record_sub_left_menu tr.active").removeClass("active");
		$("#contact_record_opmode").val("add");
	}

	function save_contact_record() {
		if(check_form("form_lianxijilu")){
      sendForm("form_lianxijilu", "<?php echo U('contact_record/save');?>",window.location.href);
		}		
	}

  function destroy_contact_record() {
    var id = $(".contact_record_sub_left_menu  tr.active").attr('id');
    if(id==undefined){
      alert('请先选择联系记录');
      return false;
    }
    sendAjax("<?php echo U('contact_record/del');?>", "id=" + id, function(data) {
        if(data['status']=='1'){
          alert(data['info']);
        }else{
          alert('未成功！'); 
        };
       location.reload();
    });
  }

	function showdata(result) {
		for (var s in result.data) {
      //alert(s);
			set_val(s,result.data[s]);
		}
    $("#contact_result_id_"+result.data['contact_result_id']).click(); 
    //if(result.data['contact_result_id'] == 1){
    //}
		//$("#dept_name").val($("#dept_list option[value='" + $("#dept_id").val() + "']").text());
		//img_url = "<?php echo C('SAVE_PATH');?>" + $("#pic").val();
		//$("#emp_pic").attr("src", img_url.split(";")[0]);
		$("#save_name").val("");
		$("#opmode").val("edit");
	}

	$(document).ready(function(){		
	//	$(".input-date").datepicker();
		$(".contact_record_sub_left_menu  tr").click(function() {
			$(".contact_record_sub_left_menu  tr.active").removeClass("active");
      $('#contact_record_opmode').val('edit');
      $('#contact_record_id').val($(this).attr('id'));
			$(this).attr("class","active");
      //alert($(this).attr('id'));
			sendAjax("<?php echo U('contact_record/read');?>", "id=" + $(this).attr("id"), function(data) {
        //alert(data);
				showdata(data);
			});
			return false;
		})
	});

</script>
<div class="admin" >
	<form method="post" action="" id="form_search" name="form_search">
		<div class="row-fluid title">
      <a href="javascript:void($('#lianxijilu').toggle())">
        <span>联系记录管理</span>
      </a>
		</div>
	</form>
  <div id="lianxijilu" style="display:none;">
	<div class="row-fluid operate" >
		<div class="right">
			<a onclick="add_contact_record()"  class="btn">新增</a>
			<a onclick="save_contact_record()"  class="btn">保存</a>
			<a onclick="destroy_contact_record()"  class="btn">删除</a>
		</div>
	</div>
	<div class="row-fluid">
		<div class="span4 contact_record_sub_left_menu ">
			<table class="table table-bordered">
				<tr>
					<th>联系时间</th>
					<th>联系人</th>
					<th>联系结果</th>
				</tr>
        <?php?>
        <?php?>
        <?php?>
				<?php if(is_array($contact_record_list)): $i = 0; $__LIST__ = $contact_record_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$lianxijilu): $mod = ($i % 2 );++$i;?><tr id="<?php echo ($lianxijilu["id"]); ?>">
						<td><?php echo ($lianxijilu["created_at"]); ?></td>
            <td><?php echo $lianxijilu['contact_person']['name'] ?></td>
            <td><?php echo $lianxijilu['contact_result_id'] == 1 ? '有效' : '无效' ?></td>
					</tr><?php endforeach; endif; else: echo "" ;endif; ?>
			</table>
		</div>
		<div class="span8">
			<form id="form_lianxijilu" name="form_lianxijilu" method="post" action="">
				<input type="hidden" id="save_name" name="save_name">
				<input type="hidden" name="id" id="contact_record_id">
				<input type="hidden" name="pid" id="contact_record_pid" value="">
        <input type="hidden" name="mini_client_id" id="contact_record_mini_client_id" value="<?php echo ($vo["id"]); ?>">
				<input type="hidden" name="pic" id="contact_record_pic" >
				<input type="hidden" name="ajax" id="contact_record_ajax" value="1">
				<input type="hidden" name="opmode" id="contact_record_opmode" value="">
				<!--<input type="hidden" name="created_user_id" id="contact_record_created_user_id" value="">-->
				<!--<select type="select-one" id="dept_list" name="dept_list" onchange="" ondblclick="" class="dis" ><?php  foreach($dept_list as $key=>$val) { ?><option value="<?php echo $key ?>"><?php echo $val ?></option><?php } ?></select>-->
				<table class="table table-bordered" >
					<tr>
						<th>联系人*</th>
            <?php  foreach ($lianxiren_list as $lxr ) { $lianxiren_select_list[$lxr['id']] = $lxr['name']; } ?>
						<td>
              <select type="select-one" id="contact_person_id" name="contact_person_id" onchange="" ondblclick="" class="input-small" ><?php  foreach($lianxiren_select_list as $key=>$val) { ?><option value="<?php echo $key ?>"><?php echo $val ?></option><?php } ?></select>
              <!--<input type="text" id="name" name="name" class="input-small" check="require" msg="请输入姓名">-->
            </td>
						<th>联系方式</th>
						<td>
              <select type="select-one" id="contact_way_id" name="contact_way_id" onchange="" ondblclick="" class="input-small" ><?php  foreach($contact_way_list as $key=>$val) { ?><option value="<?php echo $key ?>"><?php echo $val ?></option><?php } ?></select>
						</td>
					</tr>
					<tr>
						<th>联系结果*</th>
						<td colspan=3>
              <span class="span6">
                有效的联系：<input id="contact_result_id_1" checked="checked" type="radio" value="1" onclick="$('.youxiao').show();$('.wuxiao').hide();" name="contact_result_id">
              </span>
              <span class="span6">
                无效的联系:<input id="contact_result_id_0" type="radio" value="0" onclick="$('.youxiao').hide();$('.wuxiao').show();" name="contact_result_id">
              </span>
            </td>
					</tr>
					<tr class='youxiao' style=";">
						<th>介绍产品</th>
						<td colspan=3>
              <input type="text" id="introduce_product" name="introduce_product" class="span12">
						</td>
					</tr>
					<tr class='youxiao' style=";">
						<th>介绍服务</th>
						<td colspan=3>
              <input type="text" id="introduce_server" name="introduce_server" class="span12">
						</td>
					</tr>
					<tr class="youxiao" style=";">
						<th>兴趣点</th>
						<td colspan=3>
              <input type="text" id="interest_point" name="interest_point" class="span12">
						</td>
					</tr>
					<tr class='youxiao' style=";">
						<th>异议点</th>
						<td colspan=3>
              <input type="text" id="dissent_point" name="dissent_point" class="span12">
						</td>
					</tr>
					<tr class='youxiao' style=";">
						<th>沟通记录</th>
						<td colspan=3>
              <input type="text" id="description" name="description" class="span12">
						</td>
					</tr>
					<tr class='youxiao' style=";">
						<th>跟进思路</th>
						<td colspan=3>
              <input type="text" id="follow_ideas" name="follow_ideas" class="span12">
						</td>
					</tr>
					<tr class="wuxiao" style="display:none;">
						<th>联系备注</th>
						<td colspan="3">
              <input type="text" name="invalid_contact_description" id="invalid_contact_description" class="span12">
						</td>
						</td>
					</tr>
				</table>
			</form>
		</div>
    <div id="contact_record_page">
    </div>
	</div>
</div>
</div>

<script type="text/javascript">
	function add_serve_record() {
		$("#form_serve_record :input :not(:button) :not('select')").each(function() {
			$(this).val("");
		});
		$("#form_serve_record :text").each(function() {
			$(this).val("");
		});
		$("#form_serve_record select").each(function() {
			$(this).find('option:first').attr('selected', 'selected');
		});
		$(".serve_record_sub_left_menu tr.active").removeClass("active");
		$("#serve_record_opmode").val("add");
	}

	function save_serve_record() {
		if(check_form("form_serve_record")){
      sendForm("form_serve_record", "<?php echo U('serve_record/save');?>",window.location.href);
		}		
	}

  function destroy_serve_record() {
    var id = $(".serve_record_sub_left_menu  tr.active").attr('id');
    if(id==undefined){
      alert('请先选择联系记录');
      return false;
    }
    sendAjax("<?php echo U('serve_record/del');?>", "id=" + id, function(data) {
        if(data['status']=='1'){
          alert(data['info']);
        }else{
          alert('未成功！'); 
        };
       location.reload();
    });
  }

	function showdata(result) {
		for (var s in result.data) {
			set_val(s,result.data[s]);
		}
    $("#contact_result_id_"+result.data['contact_result_id']).click(); 
    $("#content").text(result.data['content']); 
		$("#save_name").val("");
		$("#opmode").val("edit");
	}

	$(document).ready(function(){		
	//	$(".input-date").datepicker();
		$("#serve_record_content").on('click',"tr",function() {
			$(".serve_record_sub_left_menu  tr.active").removeClass("active");
      $('#serve_record_opmode').val('edit');
      $('#serve_record_id').val($(this).attr('id'));
			$(this).attr("class","active");
      //alert($(this).html());
			sendAjax("<?php echo U('serve_record/read');?>", "id=" + $(this).attr("id"), function(data) {
        //alert(data);
				showdata(data);
			});
			return false;
		})
	});

</script>
<div class="admin" >
	<form method="post" action="" id="form_search" name="form_search">
		<div class="row-fluid title">
      <a href="javascript:void($('#serve_record').toggle())">
        <span>服务小计管理</span>
      </a>
		</div>
	</form>
  <div id="serve_record" style="display:none;">
	<div class="row-fluid operate" >
		<div class="right">
			<a onclick="add_serve_record()"  class="btn">新增</a>
			<a onclick="save_serve_record()"  class="btn">保存</a>
			<a onclick="destroy_serve_record()"  class="btn">删除</a>
		</div>
	</div>
	<div class="row-fluid">
		<div class="span4 serve_record_sub_left_menu ">
			<table class="table table-bordered">
				<tr id="serve_tr">
					<th>联系时间</th>
					<th>联系人</th>
					<th>客服</th>
				</tr>
        <tr>
          <td colspan=3 id="serve_record_content"> 
            <table class="table table-bordered">
  <?php if(is_array($serve_record_list)): $i = 0; $__LIST__ = $serve_record_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$serve_record): $mod = ($i % 2 );++$i;?><tr id="<?php echo ($serve_record["id"]); ?>">
    <td><?php echo ($serve_record["created_at"]); ?></td>
    <td><?php echo $serve_record['contact_person']['name'] ?></td>
    <td><?php echo $serve_record['contact_result_id'] == 1 ? '有效' : '无效' ?></td>
  </tr><?php endforeach; endif; else: echo "" ;endif; ?>
  <tr id="serve_record_page">
    <td colspan=3>
      <?php echo ($page); ?>
    </td>
  </tr>
</table>

          </td>
          <tr>
			</table>
		</div>
		<div class="span8">
			<form id="form_serve_record" name="form_serve_record" method="post" action="">
				<input type="hidden" id="save_name" name="save_name">
				<input type="hidden" name="id" id="serve_record_id">
				<input type="hidden" name="pid" id="serve_record_pid" value="">
        <input type="hidden" name="mini_client_id" id="serve_record_mini_client_id" value="<?php echo ($vo["id"]); ?>">
				<!--<input type="hidden" name="pic" id="serve_record_pic" >-->
				<input type="hidden" name="ajax" id="serve_record_ajax" value="1">
				<input type="hidden" name="opmode" id="serve_record_opmode" value="">
				<!--<input type="hidden" name="created_user_id" id="serve_record_created_user_id" value="">-->
				<!--<select type="select-one" id="dept_list" name="dept_list" onchange="" ondblclick="" class="dis" ><?php  foreach($dept_list as $key=>$val) { ?><option value="<?php echo $key ?>"><?php echo $val ?></option><?php } ?></select>-->
				<table class="table table-bordered" >
					<tr>
						<th>联系人*</th>
            <?php  foreach ($lianxiren_list as $lxr ) { $lianxiren_select_list[$lxr['id']] = $lxr['name']; } ?>
						<td>
              <select type="select-one" id="contact_person_id" name="contact_person_id" onchange="" ondblclick="" class="input-small" ><?php  foreach($lianxiren_select_list as $key=>$val) { ?><option value="<?php echo $key ?>"><?php echo $val ?></option><?php } ?></select>
              <!--<input type="text" id="name" name="name" class="input-small" check="require" msg="请输入姓名">-->
            </td>
						<th>服务方式</th>
						<td>
              <select type="select-one" id="contact_way_id" name="contact_way_id" onchange="" ondblclick="" class="input-small" ><?php  foreach($serve_way_list as $key=>$val) { ?><option value="<?php echo $key ?>"><?php echo $val ?></option><?php } ?></select>
						</td>
					</tr>
					<tr class='' style=";">
						<th>关联的订单</th>
						<td colspan=3>
              <select type="select-one" id="order_id" name="order_id" onchange="" ondblclick="" class="input-small" ><?php  foreach($order_select_list as $key=>$val) { ?><option value="<?php echo $key ?>"><?php echo $val ?></option><?php } ?></select>
						</td>
					</tr>
					<tr>
						<th>联系结果*</th>
						<td colspan=3>
              <span class="span6">
                有效的联系：<input id="contact_result_id_1" checked="checked" type="radio" value="1" onclick="$('.youxiao').show();$('.wuxiao').hide();" name="contact_result_id">
              </span>
              <span class="span6">
                无效的联系:<input id="contact_result_id_0" type="radio" value="0" onclick="$('.youxiao').hide();$('.wuxiao').show();" name="contact_result_id">
              </span>
            </td>
					</tr>
					<tr class='youxiao' style=";">
						<th>服务内容</th>
						<td colspan=3>
              <textarea rows=5 id="content" name="content" class="span12"></textarea>
              <!--<input type="textarea" rows=3 id="content" name="content" class="span12">-->
						</td>
					</tr>
					<tr class="wuxiao" style="display:none;">
						<th>联系备注</th>
						<td colspan="3">
              <input type="text" name="invalid_contact_description" id="invalid_contact_description" class="span12">
						</td>
						</td>
					</tr>
				</table>
			</form>
		</div>
    <!--<div class="page">-->
      <!--<?php echo ($page); ?>-->
    <!--</div>-->
	</div>
</div>
</div>

<script type="text/javascript">
	function add_order() {
		$("#form_order :input :not(:button) :not('select')").each(function() {
			$(this).val("");
		});
		$("#form_order :text").each(function() {
			$(this).val("");
		});
		$("#form_order select").each(function() {
			$(this).find('option:first').attr('selected', 'selected');
		});
		$(".order_sub_left_menu tr.active").removeClass("active");
		$("#order_opmode").val("add");
	}

	function save_order() {
		if(check_form("form_order")){
      sendForm("form_order", "<?php echo U('order/save');?>",window.location.href);
		}		
	}

  function destroy_order() {
    var id = $(".order_sub_left_menu  tr.active").attr('id');
    if(id==undefined){
      alert('请先选择联系记录');
      return false;
    }
    sendAjax("<?php echo U('order/del');?>", "id=" + id, function(data) {
        if(data['status']=='1'){
          alert(data['info']);
        }else{
          alert('未成功！'); 
        };
       location.reload();
    });
  }

	function showdata(result) {
		for (var s in result.data) {
			set_val(s,result.data[s]);
		}
    $('#order_id').val(result.data['id']);
    //$("#contact_result_id_"+result.data['contact_result_id']).click(); 
		$("#save_name").val("");
		$("#opmode").val("edit");
	}

	$(document).ready(function(){		
  	$(".input-date").datepicker();
		$(".order_sub_left_menu  tr").click(function() {
			$(".order_sub_left_menu  tr.active").removeClass("active");
      $('#order_opmode').val('edit');
      //alert($(this).attr('id'));
      $('#real_order_id').val($(this).attr('id'));
			$(this).attr("class","active");
			sendAjax("<?php echo U('order/read');?>", "id=" + $(this).attr("id"), function(data) {
				showdata(data);
			});
			return false;
		})
	});

</script>
<div class="admin" >
	<form method="post" action="" id="form_search" name="form_search">
		<div class="row-fluid title">
      <a href="javascript:void($('#order').toggle())">
        <span>订单管理</span>
      </a>
		</div>
	</form>
  <div id="order" style="display:none;">
	<div class="row-fluid operate" >
		<div class="right">
			<a onclick="add_order()"  class="btn">新增</a>
			<a onclick="save_order()"  class="btn">保存</a>
			<a onclick="destroy_order()"  class="btn">删除</a>
		</div>
	</div>
  <?php  ?>
	<div class="row-fluid">
		<div class="span4 order_sub_left_menu ">
			<table class="table table-bordered">
				<tr>
					<th>订单编号</th>
					<th>创建日期</th>
					<th>订单金额</th>
					<th>审核状态</th>
				</tr>
				<?php if(is_array($order_list)): $i = 0; $__LIST__ = $order_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$order): $mod = ($i % 2 );++$i;?><tr id="<?php echo ($order["id"]); ?>">
						<td><?php echo ($order["number"]); ?></td>
            <td><?php echo $order['created_at'] ?></td>
            <td><?php echo $order['contract_amount'] ?></td>
            <td><?php echo $order['check_status'] == 1 ? '审核中' : '已审核' ?></td>
					</tr><?php endforeach; endif; else: echo "" ;endif; ?>
			</table>
		</div>
		<div class="span8">
			<form id="form_order" name="form_order" method="post" action="">
				<input type="hidden" id="save_name" name="save_name">
				<input type="hidden" name="id" id="real_order_id">
				<input type="hidden" name="pid" id="order_pid" value="">
        <input type="hidden" name="mini_client_id" id="order_mini_client_id" value="<?php echo ($vo["id"]); ?>">
				<input type="hidden" name="pic" id="order_pic" >
				<input type="hidden" name="ajax" id="order_ajax" value="1">
				<input type="hidden" name="opmode" id="order_opmode" value="">
        <input type="hidden" name="number" id="order_number" value="<?php echo "000$order_count" ?>">
        <input type="hidden" name="created_at" id="order_created_at" value="<?php echo date('Y-m-d H:i:s'); ?>">
				<table class="table table-bordered" >
					<tr>
						<th>联系人*</th>
            <?php  foreach ($lianxiren_list as $lxr ) { $lianxiren_select_list[$lxr['id']] = $lxr['name']; } ?>
						<td>
              <select type="select-one" id="contact_person_id" name="contact_person_id" onchange="" ondblclick="" class="input-small" ><?php  foreach($lianxiren_select_list as $key=>$val) { ?><option value="<?php echo $key ?>"><?php echo $val ?></option><?php } ?></select>
            </td>
          </tr>
          <tr class="order_item">
						<th>产品</th>
						<td>
              <select type="select-one" id="product_id" name="product_id" onchange="" ondblclick="" class="input-small" ><?php  foreach($product_list as $key=>$val) { ?><option value="<?php echo $key ?>"><?php echo $val ?></option><?php } ?></select>
						</td>
					</tr>
					<tr class='order_item' style=";">
						<th>合同总价</th>
						<td colspan=3>
              <input type="text" id="contract_amount" name="contract_amount" class="span12">
						</td>
					</tr>
					<tr class='order_item' style=";">
						<th>已收款项</th>
						<td colspan=3>
              <input type="text" id="received_amount" name="received_amount" class="span12">
						</td>
					</tr>
					<tr class="order_item" style=";">
						<th>服务开始时间</th>
						<td colspan=3>
              <input type="text" id="serve_start_at" name="serve_start_at" class="span12 input-date">
						</td>
					</tr>
					<tr class='order_item' style=";">
						<th>服务结束时间</th>
						<td colspan=3>
              <input type="text" id="serve_end_at" name="serve_end_at" class="span12 input-date">
						</td>
					</tr>
					<tr class='order_item' style=";">
						<th>续费标准</th>
						<td colspan=3>
              <input type="text" id="fee_standard" name="fee_standard" class="span12">
						</td>
					</tr>
					<tr class="order" style="">
						<th>订单备注</th>
						<td colspan="3">
              <textarea type="text" name="description" id="description" class="span12" rows='3'></textarea>
						</td>
						</td>
					</tr>
				</table>
			</form>
		</div>
    <div id="order_page">
    </div>
	</div>
</div>
</div>


</div>
		</div>
	</div>
	<div class="msg popout"></div>
	<iframe src="<?php echo U('push/client');?>" class="push" id="push"></iframe>
	<script src="__PUBLIC__/js/bootstrap.min.js"></script>
	<script src="__PUBLIC__/js/jquery-ui-1.9.2.custom.min.js"></script>
	<script src="__PUBLIC__/js/common.js"></script>
</body>
</html>